#include <iostream>
#include <cstdlib>
#include <signal.h>
#include <unistd.h>

using namespace std;

void handler(int num)
{
    cout << "我是一个进程，我即将退出，pid：" << getpid() << endl;
    exit(1);
}

int main()
{
    signal(2, handler);
    while(true)
    {
        cout << "continue... pid : " << getpid() << endl;
        sleep(1);
    }

    return 0;
}